# coding: utf-8

import CurveEditorBoilerplate as cep
from PSOFT.vendor.Qt_py.Qt import QtCore, QtGui, QtWidgets


class Background(QtWidgets.QGraphicsItem):

    __outerPen = QtGui.QPen(QtGui.QColor("#383838"))
    __innerPen = QtGui.QPen(QtGui.QColor("#383838"))

    def __init__(self):
        super(Background, self).__init__()
        self.__outerPen.setWidth(2)
        self.__innerPen.setWidth(1)

        self.setPos(cep.VIEW_MERGIN_X, cep.VIEW_MERGIN_BOTTOM)
        self.viewWidth = cep.VIEW_WIDTH

    def type(self):
        return QtWidgets.QGraphicsItem.UserType + 3

    def boundingRect(self):
        return QtCore.QRectF(0, 0, self.viewWidth, cep.VIEW_HEIGHT)

    def paint(self, painter, option, widget):
        painter.setPen(self.__outerPen)

        painter.drawRect(-1, -1, self.viewWidth + 2, cep.VIEW_HEIGHT + 2)
        painter.setPen(self.__innerPen)
        painter.drawLine(0, cep.VIEW_HEIGHT / 2,
                         self.viewWidth, cep.VIEW_HEIGHT / 2)
        painter.drawLine(self.viewWidth * 0.25, 0,
                         self.viewWidth * 0.25, cep.VIEW_HEIGHT)
        painter.drawLine(self.viewWidth * 0.5, 0,
                         self.viewWidth * 0.5, cep.VIEW_HEIGHT)
        painter.drawLine(self.viewWidth * 0.75, 0,
                         self.viewWidth * 0.75, cep.VIEW_HEIGHT)
